<?php

class Test_Abovo_Model_Contacts_Users extends Solar_Test {
    
    protected $_users;
    
    public function setup()
    {
        $this->_users = Solar::factory('Abovo_Model_Contacts_Users');
    }
    
    public function testFetchByHandle()
    {
        $data = array(
            'handle'       => 'foobar',
            'firstname'    => 'Antti',         // goes to persons table
            'lastname'     => 'Holvikari',          // goes to persons table
            'email'        => 'antti@example.com',
            'country'      => 'FI',
            'gender'       => 0,
            'companies_id' => 1,                   // goes to contacts table
        );
        
        $this->_users->insert($data);
        
        // check that handle is there
        $user = $this->_users->fetchByHandle('foobar');
        
        $this->assertTrue(isset($user->handle));
        
        $this->assertSame($user->handle, $data['handle']);
    }
    
}
